/**
 * cookie存储
 * @param {string} key   键
 * @param {object} val   值
 * @param {number} time  时间
 */
function setCookie(key,val,time=5){
    if(typeof val=='object')val=JSON.stringify(val)
    const d=new Date   
    d.setTime(d.getTime()-1000*60*60*8+1000*time)
    document.cookie=`${key}=${val}; expires=${d}`
}
/**
 * cookie获取
 * @param {string} key 
 * @returns String 
 */
function getCookie(key){
    let arr=document.cookie.split('; ')
    for(let i=1;i<arr.length;i++){
        let item=arr[i]
        let tempArr=item.split('=')
        if(tempArr[0]==key) return tempArr[1]
    }
}
/**
 * cookie删除
 * @param {string} key 
 * @returns undefined
 */
function removeCookie(key){
    setcookie(key,null,-1)
}